package cn.wolfcode.domain;

import cn.wolfcode.enums.NoticeEnum;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Notice {
    /** */
    private Long id;

    /** */
    private String title;

    /** */
    private Employee creator;

    /** */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date creatTime;

    /** */
    private Integer level;

    /** */
    private Boolean status;

    private NoticeItem item;

    private boolean readStatus;

    public String getLevleName(){
       return NoticeEnum.fineName(level);
    }

    public String toJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("content",item.getContent());
        map.put("level",level);
        return JSON.toJSONString(map);
    }
}